package jp.ddo.trismegistos.timer.activity;

import jp.ddo.trismegistos.timer.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class TimeSettingActivity extends Activity {

	public void onCreate(final Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.time_setting);

		setRadioGroupAction();
	}

	protected void setRadioGroupAction() {
		final RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radiogroup_id);

		radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(final RadioGroup group,
					final int checkedId) {
				final RadioButton radioButton = (RadioButton) findViewById(checkedId);
				if (radioButton.isChecked()) {
					final Intent intent = new Intent();
					intent.putExtra(getString(R.string.timeSettingKey),
							checkedId);
					setResult(RESULT_OK, intent);
					finish();
				}
			}
		});
	}
}
